<!--
 * @description  : 投放建议文书
 * @descriptionDetail: 投放建议文书
 * @copyright    : 浙江烟草
 * @author       : mwq
 * @create       : 2022-09-27 09:58:58
-->
<template>
  <view>
    <!-- #ifdef H5-ONLY -->
    <theme-navbar
      :is-white="false"
      :title="title"
      :custom-back="goBack"
      style="z-index: 99999"
    >
    </theme-navbar>
    <!-- #endif -->
    <view>
      <view class="table-header">
        <u-tabs :list="tabList" :is-scroll="false" :current="current" bg-color="#dfe6e9" @change="handlerChangeTab" class="tabs"></u-tabs>
      </view>
      <view v-if="showTip" class="no-data">
        ~ 暂无数据 ~
      </view>
      <view>
        <u-card
          v-for="(item,index) in regularList"
          margin="0"
          :border="false"
          :show-foot="false"
          :show-head="false"
          :key="index"
          border-radius="0rpx"
          :full="false"
          class="card"
        >
          <template #body>
            <u-row gutter="12">
              <u-col style="font-size:24px;font-weight:bold;" span="2">
                {{ item.targetLevelText }}
              </u-col>
              <u-col style="font-size:24px;font-weight:bold;" span="7">
                {{ item.compName }}
              </u-col>
              <u-col style="color:#999;font-weight:bold;" span="3">
                {{ title }}
              </u-col>
            </u-row>
            <u-line class="u-line" color="#999" margin="20rpx"></u-line>
            <u-row gutter="12">
              <u-col style="color:#999;margin-bottom:8px;" span="8">
                规格
              </u-col>
              <u-col style="color:#999;margin-bottom:8px;" span="4">
                流程状态
              </u-col>
              <u-col style="font-size:16px;margin-bottom:8px;" span="8">
                {{ item.brandName }}
              </u-col>
              <u-col style="font-size:16px;margin-bottom:8px;" span="4">
                {{ item.processStateName }}
              </u-col>
              <u-col style="color:#999;margin-bottom:8px;" span="16">
                触发建议规则
              </u-col>
              <u-col style="font-size:16px;margin-bottom:8px;" span="16">
                {{ item.temp2 }}
              </u-col>
            </u-row>
            <u-row gutter="12" v-if="current=='1'">
              <u-col style="color:#999;margin-bottom:8px;" span="16">
                营销反馈
              </u-col>
              <u-col style="font-size:16px;margin-bottom:8px;" span="12">
                {{ item.marketingBack }}
              </u-col>
              <u-col style="color:#999;margin-bottom:8px;" span="16">
                下一步投放规则
              </u-col>
              <u-col style="font-size:16px;margin-bottom:8px;" span="12">
                {{ item.marketingDetail }}
              </u-col>
            </u-row>
            <u-line class="u-line" color="#999" margin="20rpx"></u-line>
            <u-form label-position="top" style="margin:10px" v-if="current=='0'">
              <u-form-item
                label="营销反馈"
                required="true"
              >
                <u-radio-group v-model="item.marketingBack">
                  <u-radio 
                    v-for="(item, index) in radiolist" 
                    :key="index"
                    :name="item.value"
                    :label="item.name"
                  >
                    {{ item.name }}
                  </u-radio>
                </u-radio-group>
              </u-form-item>
              <u-form-item
                label="下一步投放安排"
              >
                <u-input
                  type="textarea"
                  placeholder="请输入"
                  v-model="item.marketingDetail"
                  :autoHeight="false"
                />
              </u-form-item>
            </u-form>
            <u-row gutter="12" v-if="current=='0'">
              <u-col offset="8" span="12" align="right">
                <u-button size="medium" type="primary" @click="handleSubmit(item)">
                  提交
                </u-button>
              </u-col>
            </u-row>
          </template>
        </u-card>
      </view>
    </view>
  </view>
</template>
<script>
import { ZDictSelect, } from "@/components";
import approval from "@/service/internal/approval.service.js";
export default {
  components:{},
  data(){
    return{
      formData: {
        marketingBack:'',
        marketingBackCode:'',
        marketingDetail:'',
      },
      labelWidth: 200,
      tabList:[
        {
          name:'待反馈',
        },{
          name:'已反馈',
        },],
      current:0,
      list:[
        
      ],
      parse:{},
      regularList:[],
      title:'',
      radiolist:[
        {
          name:"采纳",
          value: '采纳',
          disabled: true,
        },
        {
          name:"不采纳",
          value: '不采纳',
          disabled: true,
        },
        {
          name:"未调整",
          value: '未调整',
          disabled: true,
        },
      ],
      showTip:false,
    };
  },
  created(){
    this.loadData();
  },
  onLoad(opt) {
    this.parse = opt;
    this.title = opt.title;
  },
  methods:{
    handlerChangeTab(index){
      this.current = index;
      this.loadData();
    },
    loadData(){
      let params = {
        reportId:this.parse.regularReportUuid,
        managerSuggestionCode:this.parse.managerSuggestionCode,
        processState:this.current == 0 ? '02' : '03',
      }
      return approval.regularReportList(params).then((d) => {
        if(d.data.length == 0){ this.showTip = true }else{ this.showTip = false }
        this.regularList = d.data;
      });
    },
    handleSubmit(item){
      if(!item.marketingBack){
        this.$u.toast('请选择营销反馈')
        return false
      }
      let dictList = this.$u.dic.getByDictCode("I_NG_ZXXT_SURE");
      dictList.forEach((d) => {
        if(item.marketingBack == d.bcbName){
          item.marketingBackCode = d.bcbCode
        }
      });
      return approval.regularReportFeedback(item).then((res) => {
        if(res.success ){
          this.$u.toast('反馈成功');
          this.loadData();
        }else{ 
          this.$u.error('反馈失败'); 
        }
      });
    },
  },
}
</script>
<style lang="scss" scoped>
	.card{
         border-width: 10px;
         border-color:#ecebeb;
         border-bottom-style: solid;
  }
  .tabs{
  position: fixed;
  bottom: 0px;
  width:100%;
  z-index: 999;
  background-color: rgb(126, 125, 125);
  }
  .no-data{
	text-align: center;
  margin: 20px;
}
</style>